package com.example.demo.entryWarehouse.controller;


import com.example.demo.common.ResponseData;
import com.example.demo.entryWarehouse.dto.AcceptGood;
import com.example.demo.entryWarehouse.entity.AcceptGoods;
import com.example.demo.entryWarehouse.mapper.AcceptGoodsMapper;
import com.example.demo.entryWarehouse.service.AcceptGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangxuan
 * @since 2021-05-03
 */
@RestController
@RequestMapping("/entryWarehouse/accept-goods")
@PreAuthorize("hasAnyAuthority('4','5')")
@CrossOrigin(origins = {"*"})
public class AcceptGoodsController {
    @Autowired
    private AcceptGoodsService acceptGoodsService;

    //验收物品
    @PostMapping("/addGood")
    public ResponseData addGood(@RequestBody AcceptGood acceptGood){
        return acceptGoodsService.addGood(acceptGood);
    }

    //更改验收信息
    @PostMapping("/editGood")
    public ResponseData editGood(@RequestBody AcceptGoods acceptGoods){
        return  acceptGoodsService.editGood(acceptGoods);
    }

    //加载未完成验收记录通过编号
    @GetMapping("/selectById")
    public ResponseData selectById(@RequestParam("acceptId") String acceptId){
        return acceptGoodsService.selectById(acceptId);
    }

    //删除某验收物品
    @PostMapping("/removeGood")
    public ResponseData removeGood(@RequestParam("id") String id){
        return acceptGoodsService.removeGood(id);
    }



}

